﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.DB;
using YJKArchMethodLibrary.Utils;

namespace YJKElementFinish.ColumnSurface.DataDefinition
{
	public class WallTypeLayerInfos
	{
		public string TypeName { get; set; }

		public int FirstCoreLayerIndex { get; set; }

		public int LastCoreLayerIndex { get; set; }

		public List<WallLayerInfos> LayerList
		{
			get
			{
				return this.m_LayerList;
			}
			set
			{
				this.m_LayerList = value;
			}
		}

		public bool HasStructureLayer()
		{
			foreach (WallLayerInfos wallLayerInfos in this.m_LayerList)
			{
                if ((int)wallLayerInfos.StructureLayer.Function == 1)
				{
					return true;
				}
			}
			return false;
		}

		public List<CompoundStructureLayer> StructureLayerList()
		{
			List<CompoundStructureLayer> list = new List<CompoundStructureLayer>();
			foreach (WallLayerInfos wallLayerInfos in this.m_LayerList)
			{
				list.Add(wallLayerInfos.StructureLayer);
			}
			return list;
		}

		public double Width
		{
			get
			{
				double num = 0.0;
				foreach (WallLayerInfos wallLayerInfos in this.m_LayerList)
				{
					double val = Convert.ToDouble(wallLayerInfos.Thickness);
					num += Common.MMToFeet(val);
				}
				return num;
			}
		}

		public WallTypeLayerInfos(WallTypeLayerInfos other)
		{
			this.TypeName = other.TypeName;
			this.FirstCoreLayerIndex = other.FirstCoreLayerIndex;
			this.LastCoreLayerIndex = other.LastCoreLayerIndex;
			this.m_LayerList = other.LayerList;
		}

		public WallTypeLayerInfos DeepClone()
		{
			List<WallLayerInfos> list = new List<WallLayerInfos>();
			foreach (WallLayerInfos wallLayerInfos in this.m_LayerList)
			{
				list.Add(wallLayerInfos.DeepClone());
			}
			return new WallTypeLayerInfos(this.TypeName, this.FirstCoreLayerIndex, this.LastCoreLayerIndex, list);
		}

		public WallTypeLayerInfos(string typeName, int interiorKernelLayerIndex, int exteriorKernelLayerIndex, List<WallLayerInfos> layerList)
		{
			this.TypeName = typeName;
			this.FirstCoreLayerIndex = interiorKernelLayerIndex;
			this.LastCoreLayerIndex = exteriorKernelLayerIndex;
			this.m_LayerList = layerList;
		}

		public void Update(Document doc)
		{
			foreach (WallLayerInfos wallLayerInfos in this.m_LayerList)
			{
				wallLayerInfos.Update(doc);
			}
		}

		private List<WallLayerInfos> m_LayerList = new List<WallLayerInfos>();
	}
}
